import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

// 解决导航栏或者底部导航tabBar中的vue-router在3.0版本以上频繁点击菜单报错的问题。
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location) {
  return originalPush.call(this, location).catch(err => err)
}

const routes = [
  {
    path: '/',
    name: 'Manager',
    component: () => import('../views/Manager.vue'),
    redirect: '/homec',  // 重定向到主页
    children: [
      { path: '403', name: 'NoAuth', meta: { name: '无权限' }, component: () => import('../views/manager/403') },
      { path: 'homec', name: 'HomeCopy', meta: { name: '系统首页' }, component: () => import('../views/manager/HomeCopy') },
      { path: 'admin', name: 'Admin', meta: { name: '管理员信息' }, component: () => import('../views/manager/Admin') },
      { path: 'userRepair', name: 'UserRepair', meta: { name: '用户报修' }, component: () => import('../views/manager/UserRepair') },
      { path: 'userRepairAdd', name: 'UserRepairAdd', meta: { name: '用户新报修' }, component: () => import('../views/manager/UserRepairAdd') },
      { path: 'userRepairCheck', name: 'UserRepairCheck', meta: { name: '用户报修详情' }, component: () => import('../views/manager/UserRepairCheck') },
      { path: 'userRepairDetail', name: 'UserRepairDetail', meta: { name: '用户报修详情' }, component: () => import('../views/manager/UserRepairDetail') },
      { path: 'workerRepair', name: 'WorkerRepair', meta: { name: '维修管理' }, component: () => import('../views/manager/WorkerRepair') },
      { path: 'workerRepairCheck', name: 'WorkerRepairCheck', meta: { name: '维修记录' }, component: () => import('../views/manager/WorkerRepairCheck') },
      { path: 'workerRepairDetail', name: 'WorkerRepairDetail', meta: { name: '维修详情' }, component: () => import('../views/manager/WorkerRepairDetail') },
      { path: 'adminPerson', name: 'AdminPerson', meta: { name: '个人信息' }, component: () => import('../views/manager/AdminPerson') },
      { path: 'user', name: 'User', meta: { name: '用户信息' }, component: () => import('../views/manager/User') },
      { path: 'userPerson', name: 'UserPerson', meta: { name: '个人信息' }, component: () => import('../views/manager/UserPerson') },
      { path: 'workerPerson', name: 'WorkerPerson', meta: { name: '个人信息' }, component: () => import('../views/manager/WorkerPerson') },
      { path: 'category', name: 'Category', meta: { name: '维修类型' }, component: () => import('../views/manager/Category') },
      { path: 'state', name: 'State', meta: { name: '维修状态' }, component: () => import('../views/manager/State') },
      { path: 'repair', name: 'Repair', meta: { name: '报修单管理' }, component: () => import('../views/manager/Repair') },
    ]
  },
  { path: '/login', name: 'Login', meta: { name: '登录' }, component: () => import('../views/LoginWe.vue') },
  { path: '/register', name: 'Register', meta: { name: '注册' }, component: () => import('../views/Register.vue') },
  { path: '*', name: 'NotFound', meta: { name: '无法访问' }, component: () => import('../views/404.vue') },
  
] 

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
